package networking.messages.playerMessages;

import logic.common.player.Player;
import logic.common.team.Fraction;
import main.AbsInitGame;
import main.InitGame;

public class PlayerAddMessage extends PlayerMessage {
	
	private Fraction fraction, enemyFraction;
	private String name;
	private boolean isHuman, isAlive;
	private int kills, deaths, spawnObjectID;
	private short playerShortID;
	
	public PlayerAddMessage() {
		super();
	}
	
	public PlayerAddMessage(Player player) {
		super(player.getID());
		
		fraction = player.getTeam().getFraction();
		enemyFraction = player.getEnemyTeam().getFraction();
		name = player.getName();
		isHuman = player.isHuman();
		kills = player.getKills();
		deaths = player.getDeaths();
		isAlive = player.isAlive();
		if(player.getCurrentSpawnPosition() != null) 
			spawnObjectID = player.getCurrentSpawnPosition().getID();
		
		AbsInitGame init = InitGame.get();
		if(isHuman && init.isServer() && player != player.getTeam().getGame().getCurrentPlayer()) 
			playerShortID = init.getServerState().getPlayerShortID(playerID);
	}
	
	public Fraction getFraction() { return fraction; }
	
	public Fraction getEnemyFraction() { return enemyFraction; }
	
	public String getName() { return name; }
		
	public boolean isHuman() { return isHuman; }
	
	public int getKills() { return kills; }
	
	public int getDeaths() { return deaths; }
	
	public short getPlayerShortID() { return playerShortID; }
	
	public boolean isAlive() { return isAlive; }
	
	public int getSpawnObjectID() { return spawnObjectID; }
}